//
//  NavController.swift
//  sina
//
//  Created by 江先铨 on 15/11/17.
//  Copyright © 2015年 jxqstatic. All rights reserved.
//

import UIKit

class NavController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    
        
    }
    
    override func pushViewController(viewController: UIViewController, animated: Bool) {
        if self.childViewControllers.count != 0 {
        
            viewController.navigationItem.backBarButtonItem = UIBarButtonItem(title: "返回", style: .Plain, target: self, action: "back")
        }
        
        
        super.pushViewController(viewController, animated: true)
        
    }

    @objc private func back() {

        navigationController?.popToRootViewControllerAnimated(true)
    }

}
